 <template>
  <div class="wrapper">
    <el-row>
      <el-col :span="24">
        <div class="header">
          <h3 style="float: left">项目申请基本信息修改</h3>
          <el-button
            size="small"
            round
            style="background-image: linear-gradient(#e9f0e9, white);float:right; margin: 14px 50px 0 0;"
            @click="back()"
            >返 回</el-button
          >
          <!-- <h5 class="title">您当前修改的项目是<em style="color: #367fa9">{{title}}</em></h5> -->
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <div class="intro">
          <font size="4.7" face="微软雅黑">
            <strong>基本数据</strong>
          </font>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form
          style="padding-left:180px"
          :model="form"
          size="medium"
          ref="form"
          :rules="rules"
          label-width="100px"
          class="demo-ruleForm"
          :disabled="false"
        >
          <el-col :span="18">
            <el-form-item label="课题名称" prop="title">
              <el-input
                class="cell-width"
                v-model="form.title"
                prefix-icon="el-icon-postcard"
                placeholder="请勿超过100个汉字"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="研究方向" prop="research_direction">
              <el-input
                class="cell-width"
                v-model="form.research_direction"
                prefix-icon="el-icon-rank"
                placeholder="请输入研究方向"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="主题词" prop="theme">
              <el-input
                class="cell-width"
                v-model="form.theme"
                prefix-icon="el-icon-attract"
                placeholder="请输入主题词，以分号隔开（至多四个）"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="工作单位" prop="unit">
              <el-input
                class="cell-width"
                v-model="form.unit"
                prefix-icon="el-icon-school"
                placeholder="请按单位和部门公章填写全称"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="计划完成时间">
              <el-date-picker
                v-model="form.finish_time"
                type="date"
                prefix-icon="el-icon-date"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="字数">
              <el-input
                style="width: 77%"
                v-model.number="form.word_count"
                prefix-icon="el-icon-document-copy"
                placeholder="请输入最终成果字数"
              ></el-input>
              <span>
                <strong>(万字)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="通讯地址" prop="unit">
              <el-input
                class="cell-width"
                v-model="form.postal_address"
                prefix-icon="el-icon-school"
                placeholder="请按照地区名，街道名及门牌号填写"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="邮政编码" prop="unit">
              <el-input
                class="cell-width"
                v-model.number="form.post_code"
                prefix-icon="el-icon-school"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="21">
              <el-tooltip
                class="item"
                effect="dark"
                content="至少勾选一项至多两项"
                placement="top-start"
              >
                <el-form-item label="预计成果形式" prop="result">
                  <el-checkbox-group
                    style="width:100%"
                    v-model="result"
                    :min="1"
                    :max="2"
                  >
                    <el-checkbox
                      v-for="item in resultAll"
                      :key="item"
                      :label="item"
                    >{{ item }}</el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
              </el-tooltip>
            </el-col>
           <el-col :span="7">
              <el-form-item label="项目资助类别" prop="train_support">
                <el-select
                  class="cell-width"
                  v-model="form.train_support"
                >
                  <el-option
                    v-for="item in support"
                    :key="item.value"
                    :label="item.title"
                    :value="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否同意进行类别调剂：" prop="train_support_tj">
                <template>
                  <el-radio v-model="form.train_support_tj" label="1">调剂</el-radio>
                  <el-radio v-model="form.train_support_tj" label="2">不调剂</el-radio>
                </template>
              </el-form-item>
            </el-col>
        </el-form>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24" class="apply_expense">经费预算（单位：万元）</el-col>
      <el-col :span="24">
        <el-form
          :model="formExpense"
          label-width="100px"
          style="padding-left: 10%"
        >
          <el-col :span="5">
            <el-form-item label="书本费" prop="book_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  class="expense-width"
                  v-model="formExpense.book_fee"
                  placeholder="请输入书本费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途">
              <el-input
                class="cell-width"
                v-model="formExpense.book_fee_basis"
                placeholder="请输入书本费预算的依据及用途"
                type="textarea"
                maxlength="200"
                show-word-limit
                autosize
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="数据采集费" prop="book_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  class="expense-width"
                  v-model="formExpense.data_fee"
                  placeholder="请输入采集费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="book_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.data_fee_basis"
                placeholder="请输入数据采集费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="差旅费" prop="travel_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  class="expense-width"
                  v-model="formExpense.travel_fee"
                  placeholder="请输入差旅费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="travel_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.travel_fee_basis"
                placeholder="请输入差旅费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="会议费" prop="meeting_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.meeting_fee"
                  placeholder="请输入会议费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="meeting_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.meeting_fee_basis"
                placeholder="请输入会议费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="国际合作费" prop="international_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.international_fee"
                  placeholder="请输入合作费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="international_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.international_fee_basis"
                placeholder="请输入国际交流合作费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="设备费" prop="equipment_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.equipment_fee"
                  placeholder="请输入设备费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="equipment_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.equipment_fee_basis"
                placeholder="请输入设备费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="专家咨询费" prop="consulting_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.consulting_fee"
                  placeholder="请输入咨询费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="consulting_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.consulting_fee_basis"
                placeholder="请输入专家咨询费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="劳务费" prop="labour_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.labour_fee"
                  placeholder="请输入劳务费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="labour_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.labour_fee_basis"
                placeholder="请输入劳务费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="印刷费" prop="print_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.print_fee"
                  placeholder="请输入印刷费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="book_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.print_fee_basis"
                placeholder="请输入印刷费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="管理费" prop="administration_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.administration_fee"
                  placeholder="请输入管理费金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="administration_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.administration_fee_basis"
                placeholder="请输入管理费预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="其他支出" prop="other_fee">
              <el-tooltip
                class="item"
                effect="dark"
                content="以“万元”为单位填写数字"
                placement="top-start"
              >
                <el-input
                  class="expense-width"
                  oninput="value=value.replace(/[^\d.]/g, '')"
                  v-model="formExpense.other_fee"
                  placeholder="请输入金额"
                ></el-input>
              </el-tooltip>
              <span>
                <strong>(万元)</strong>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label="依据及用途" prop="other_fee_basis">
              <el-input
                class="cell-width"
                type="textarea"
                autosize
                v-model="formExpense.other_fee_basis"
                placeholder="请输入其他支出预算的依据及用途"
                maxlength="200"
                show-word-limit
              ></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <div style="text-align:center">
          <h4 style="display: inline-block">主要参与人员修改</h4>
          <el-tooltip
            class="item"
            effect="dark"
            content="点击添加人员信息,至多4人"
            placement="top-start"
          >
            <el-button
              size="mini"
              style="margin-left: 10px"
              type="primary"
              icon="el-icon-plus"
              @click="
                dialogFormVisible = true
                addPer()
              "
            ></el-button>
          </el-tooltip>
        </div>
      </el-col>
      <!-- <el-col :span="7">
      <el-tooltip class="item" effect="dark" content="点击添加人员信息" placement="top-start">
        <el-button
          size="mini"
          style="float:right"
          type="primary"
          icon="el-icon-plus"
          @click="dialogFormVisible = true"
        ></el-button>
      </el-tooltip>
      </el-col> -->
      <el-col :span="24" class="people-table">
        <el-table :data="tableData" border style="width: 100%">
          <el-table-column prop="index" type="index" label="id" width="40">
          </el-table-column>
          <el-table-column prop="name" label="姓名" width="150">
          </el-table-column>
          <el-table-column
            :formatter="sexShow"
            prop="sex"
            label="性别"
            width="50"
          >
          </el-table-column>
          <el-table-column prop="idnumber" label="身份证号" width="180">
          </el-table-column>
          <el-table-column prop="jobrank" label="职称" width="150">
          </el-table-column>
          <el-table-column prop="expertise" label="研究专长" width="170">
          </el-table-column>
          <el-table-column prop="edu" label="学历" width="130">
          </el-table-column>
          <el-table-column prop="task" label="承担任务"> </el-table-column>
          <el-table-column label="操作" width="">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="success"
                icon="el-icon-edit"
                @click="
                  dialogFormVisible = true
                  updatePeo(scope.row)
                "
                >修改</el-button
              >
              <el-button
                size="mini"
                type="warning"
                icon="el-icon-delete"
                @click="deletePeo(scope.row)"
                >删除</el-button
              >
            </template>
            <el-dialog
              width="35%"
              title="人员信息"
              :visible.sync="dialogFormVisible"
              :append-to-body="true"
            >
              <el-form :model="formPer" ref="formPer" :rules="rulesOne">
                <table class="content" border cellspacing="0">
                  <tr>
                    <td class="left"><span class="red">*</span>姓名</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="参与人员的姓名，请认真填写"
                        v-model="formPer.name"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>性别</td>
                    <td class="right">
                      <el-select v-model="formPer.sex">
                        <el-option
                          v-for="item in sexs"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        >
                        </el-option>
                        <!-- <el-option value="男">男</el-option>
                        <el-option value="女">女</el-option> -->
                      </el-select>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>身份证号</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="请按照身份证号格式输入"
                        v-model="formPer.idnumber"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                   <tr>
                    <td class="left"><span class="red">*</span>手机号</td>
                    <td class="right">
                      <el-input type="text" placeholder="请输入手机号" v-model="formPer.phone" clearable></el-input>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>职称</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="请输入职称名称"
                        v-model="formPer.jobrank"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                    <tr>
                        <td class="left"><span class="red">*</span>职务(身份)</td>
                        <td class="right">
                          <el-input
                            type="text"
                            placeholder="请输入职务名称"
                            v-model="formPer.work"
                            clearable
                          ></el-input>
                        </td>
                      </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>研究专长</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="请输入研究专长"
                        v-model="formPer.expertise"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>承担任务</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="请输入承担任务"
                        v-model="formPer.task"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>学历</td>
                    <td class="right">
                      <el-select
                        type="text"
                        placeholder="请选择学历"
                        v-model="formPer.edu"
                        clearable
                      >
                        <el-option
                          v-for="item in edus"
                          :key="item.value"
                          :label="item.label"
                          :value="item.label"
                        ></el-option>
                      </el-select>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>学位</td>
                    <td class="right">
                      <el-select
                        type="text"
                        placeholder="请选择学位"
                        v-model="formPer.degree"
                        clearable
                      >
                        <el-option
                          v-for="item in degrees"
                          :key="item.value"
                          :label="item.label"
                          :value="item.label"
                        ></el-option>
                      </el-select>
                    </td>
                  </tr>
                  <tr>
                    <td class="left"><span class="red">*</span>工作单位</td>
                    <td class="right">
                      <el-input
                        type="text"
                        placeholder="请按单位和部门公章填写全称"
                        v-model="formPer.unit"
                        clearable
                      ></el-input>
                    </td>
                  </tr>
                </table>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="servePer(formPer)"
                  >确 定</el-button
                >
              </div>
            </el-dialog>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
     <el-col :span="24" class="apply_expense">项目背景</el-col>
      <el-row>
        <el-col :span="22">
          <div style="margin-left: 10%;">
              <UE
              :config="config"
              v-model="background"
              ref="editor1"
              :id="editor1"
              :defaultMsg="请输入内容"
            ></UE>
          </div> 
        </el-col>
      </el-row>
     <el-col :span="24" class="apply_expense">项目简介（限500字以内）</el-col>
      <el-row>
        <el-col :span="22">
          <div style="margin-left: 10%;">
            <UE
              v-model="introduction"
              :config="config"
              ref="editor2"
              :id="editor2"
              :defaultMsg="请输入内容"
            ></UE>
          </div> 
        </el-col>
      </el-row>
      <el-col :span="24" class="apply_expense">项目方案（限5000字以内）</el-col>
      <el-row>
        <el-col :span="22">
          <div style="margin-left:10%;">
            <UE
              v-model="plan"
              :config="config1"
              ref="editor3"
              :id="editor3"
              :defaultMsg="请输入内容"
            ></UE>
          </div> 
        </el-col>
      </el-row>
      <el-col :span="24" class="apply_expense">学校提供条件</el-col>
      <el-row>
        <el-col :span="22">
          <div style="margin-left: 10%;">
            <UE
              v-model="schsupport"
              :config="config"
              ref="editor4"
              :id="editor4"
              :defaultMsg="请输入内容"
            ></UE>
          </div> 
        </el-col>
      </el-row>
      <el-col :span="24" class="apply_expense">预期成果</el-col>
      <el-row>
        <el-col :span="22">
          <div style="margin-left: 10%;">
            <UE
              v-model="result_1"
              :config="config"
              ref="editor5"
              :id="editor5"
              :defaultMsg="请输入内容"
            ></UE>
          </div> 
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="7">
          <p style="margin-top:10%;margin-left:35%;">附件上传:</p>
        </el-col>
        <el-col :span="7" >
          <div style="margin-left: -40%;margin-top: 8%;">
            <el-upload
              class="upload-demo"
              action="http://8.142.34.26:8097/php/index.php/admin/Upload/SupportInput"
              :data="{pid: '2'}"
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :on-success="handleSuccess"
              :before-remove="beforeRemove"
              multiple
              :limit="3"
              :on-change="handleChange"
              :on-exceed="handleExceed"
              :file-list="fileList">
              <el-button size="small" type="primary">点击上传</el-button>
              <div slot="tip" class="el-upload__tip">只能zip/doc/xls/rap上传文件，且不超过100MB</div>
              </el-upload>
            </div>
        </el-col>
      </el-row>
    <el-row>
      <el-col :span="24" style="text-align:center;padding-top: 40px">
        <el-button type="primary" @click="submitCheck(form, subproject)"
          >提交修改</el-button
        >
      </el-col>
    </el-row>
  </div>
</template>

<script>
import http from '../../../../assets/js/http.js'
import UE from '../../../ue.vue'
 const Options = ['专著', '教材', '论文', '研究报告']
export default {
  props: {},
  data() {
    return {
      fileList: [],
      options2:[],
      editor1:'editor1',
      editor2:'editor2',
      editor3:'editor3',
      editor4:'editor4',
      editor5:'editor5',
      background:'<p>请输入内容<p/>',
      schsupport:'<p>请输入内容<p/>',
      introduction: '<p>请输入内容<p/>',
      plan: '<p>请输入内容<p/>',
      result_1: '<p>请输入内容<p/>',
      config: {
        initialFrameWidth: '100%',
        initialFrameHeight: 150,
        maximumWords:500
      },
      config1: {
        initialFrameWidth: '100%',
        initialFrameHeight: 150,
        maximumWords:5000
      },
      partner: [],
      dialogFormVisible: false,
      tableData: [],
      resultAll: Options,
      result: [],
      userInfo: Lockr.get('userInfo'),
      support: Lockr.get('support'),
      title: '',
      edus: [
        {
          label: '博士研究生',
          value: '1'
        },
        {
          label: '硕士研究生',
          value: '2'
        },
        {
          label: '大学本科',
          value: '3'
        },
        {
          label: '大学专科',
          value: '4'
        },
        {
          label: '高中',
          value: '5'
        },
        {
          label: '其他',
          value: '6'
        }
      ],
      degrees: [
        {
          label: '博士',
          value: '1'
        },
        {
          label: '硕士',
          value: '2'
        },
        {
          label: '学士',
          value: '3'
        },
        {
          label: '其他',
          value: '4'
        }
      ],
      sexs: [
        {
          label: '男',
          value: 1
        },
        {
          label: '女',
          value: 2
        }
      ],
      form: {
        title: '',
        theme: '',
        research_direction: '',
        finish_time: '',
        word_count: '',
        unit: '',
        postal_address: '',
        post_code: '',
        // achievement: '',
        id: '',
        file_id: '',
        train_support_tj: '',
        train_support: '',
        schsupport: '',
        introduction: '',
        plan: '',
        result_1: '',
        background: '',
      },
      //  rules: {
      //   result: [
      //   {
      //     type: 'array', required: true, message: '请至少选择一个预计成果形式', trigger: 'change'
      //   }],
       
      // },
      tips: {
        titleTips: '课题名称',
        themeTips: '主题词',
        research_directionTips: '研究方向',
        finish_timeTips: '计划完成时间',
        word_countTips: '字数',
        unitTips: '工作单位',
        postal_addressTips: '通讯地址',
        post_codeTips: '邮编',
        resultTips:'最终成果形式'
      },
      formExpense: {
        book_fee: '',
        book_fee_basis: '',
        data_fee: '',
        data_fee_basis: '',
        travel_fee: '',
        travel_fee_basis: '',
        international_fee: '',
        international_fee_basis: '',
        labour_fee: '',
        labour_fee_basis: '',
        administration_fee: '',
        administration_fee_basis: '',
        print_fee: '',
        print_fee_basis: '',
        equipment_fee: '',
        equipment_fee_basis: '',
        consulting_fee: '',
        consulting_fee_basis: '',
        meeting_fee: '',
        meeting_fee_basis: '',
        other_fee: '',
        other_fee_basis: ''
      },
      formPer: {
        name: '',
        sex: 0,
        idnumber: '',
        task: '',
        phone: '',
        jobrank: '',
        expertise: '',
        edu: '',
        degree: '',
        unit: '',
        work: ''
      },
      project_id:'',
      tipsOne: {
        nameTips: '姓名',
        sexTips: '性別',
        idnumberTips: '身份证号',
        taskTips: '承担任务',
        jobrankTips: '职务',
        expertiseTips: '研究专长',
        eduTips: '学历',
        degreeTips: '学位',
        unitTips: '工作单位',
        phone: '手机号',
        work: '职务'
      },
      status: '0',
      checkResultOne: '',
      last: '',
      ids: [],
      index: '',
      schsupport: "",
      result_1: "",
      plan: '',
      introduction: '',
      background: '',
      parent: ''
    }
  },
  methods: {
    //点击文件列表中已上传文件进行下载
    handlePreview(file) {
     // console.log(file.url)
      var a = document.createElement('a');
      var event = new MouseEvent('click');
      a.download = file.name;
      a.href = 'http://' + file.url;
      a.dispatchEvent(event);
      // console.log(file)
    },
    handleSuccess (response, file, fileList) {
      console.log(response.data.file_id)
      this.form.file_id = response.data.file_id
    },
    handleChange(file, fileList) {
        this.fileList = fileList.slice(-3);
    },
    beforeRemove(file, fileList) {
      console.log(fileList)
       this.form.file_id  = null
        return this.$confirm(`确定移除 ${ file.name }？`);
        
    },
    // 返回上一个界面
    back() {
      this.$router.push({
        name: 'detailpro',
        params: {
          id: this.project_id,
          saveData: this.$route.params.saveData,
          reData: this.$route.params.reData,
          parent: this.parent
        }
      })
    },
    // 初始化函数
    init() {
      this.getSupportType()
    },
    // 多选框变化时触发函数
    mulCheck(value) {
      console.log(value)
      console.log(this.result)
    },
    // 修改表格单人信息
    updatePeo(perMsg) {
      // console.log(perMsg)
      this.index = this.tableData.indexOf(perMsg)
      this.last = 2
      let curList = JSON.parse(JSON.stringify(perMsg))
      this.formPer = curList
    },
    // 删除表格单人信息
    deletePeo(perMsg) {
      // console.log(perMsg)
      var rowind = this.tableData.indexOf(perMsg)
      let curList = JSON.parse(JSON.stringify(perMsg))
      // var index = -1
      this.$confirm('此操作将永久删除该成员, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
          // 删除操作
          if (curList.id != undefined) {
            this.ids.push(curList.id)
          }
          this.partner.splice(rowind, 1)
          this.tableData = this.partner
          // let array = JSON.parse(JSON.stringify(this.partner))
          // for (let i = 0; i < array.length; i++) {
          //   console.log(array[i].id)
          //   if(curList.id === array[i].id) {
          //     index = i
          //     break
          //   }
          // }
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 对于主要成员信息操作之前的验证
    check(curList) {
      this.checkResultOne = this.checkList(curList, [
        {
          name: 'jobrank',
          reg: ['notnull']
        },
        {
          name: 'name',
          reg: ['notnull']
        },
        {
          name: 'sex',
          reg: ['notnull']
        },
        {
          name: 'idnumber',
          reg: ['notnull']
        },
        {
          'name':'work',
          'reg':['notnull']
        },
        {
          name: 'expertise',
          reg: ['notnull']
        },
        {
          name: 'edu',
          reg: ['notnull']
        },
        {
          name: 'degree',
          reg: ['notnull']
        },
        {
          name: 'unit',
          reg: ['notnull']
        },
        {
          name: 'phone',
          reg: ['notnull']
        }
      ])
    },
    // 增加人员信息
    addPer() {
      this.last = 1
      if (this.tableData.length >= 4) {
        _g.toastMsg('warning', '人数已达上限,不可再添加')
        this.dialogFormVisible = false
      } else {
        this.formPer = {}
      }
    },
    // dialog确定后保存人员信息入数组
    servePer(perMsg) {
      //console.log(perMsg)
      let curList = JSON.parse(JSON.stringify(perMsg))
      this.check(curList)
      if (_g.j2s(this.checkResultOne) === '{}') {
        this.dialogFormVisible = false
        // console.log(this.partner)
        let array = JSON.parse(JSON.stringify(this.partner))
        if (this.last === 1) {
          // add
          array.push(curList)
          this.last = ''
        }
        if (this.last === 2) {
          // 对当前修改的成员的信息进行修改
          for (let i = 0; i < array.length; i++) {
            const element = array[i]
            if (i === this.index) {
              array[i] = curList
            }
          }
          this.last = ''
        }
        this.partner = array
        this.tableData = this.partner
      //  console.log(this.partner)
      } else {
        for (const key in this.checkResultOne) {
          this.dialogFormVisible = true
          _g.toastMsg('warning', this.tipsOne[key] + this.checkResultOne[key])
          break
        }
      }
    },
    // 获取项目类别的label
    // getSupportType() {
    //   let data = {}
    //   this.apiPost('admin/Report/DropdowmList', data).then((res) => {
    //     this.handelResponse(res, (data) => {
    //       Lockr.set('support', data.support)
    //     })
    //   })
    // },
    // 获取子项目所有相关信息便于查看
    getAllMsg() {
      let data = {
        id: this.$route.params.id
      }
      console.log(data)
      this.apiPost('admin/Report/ChildrenList', data).then(res => {
        this.handelResponse(res, data => {
          // console.log(typeof(res.data.file.url))
          if(res.data.file.url !== ""){
            this.fileList.push(data.file)
          }
          // console.log(this.fileList)
          this.tableData = data.partner
          this.partner = data.partner
          this.project_id = data.subproject[0].project_id
          this.form = data.subproject[0]
          this.formExpense = data.fund[0]
          this.title = data.subproject[0].title
          this.form.postal_address = data.subproject[0].postal_address
          this.form.train_support_tj = String(data.subproject[0].train_support_tj)
          // console.log(this.background)
          this.background = data.subproject[0].background 
          // console.log(this.background)
          //window.UE.getEditor('editor1').setContent(this.background)
          this.introduction = data.subproject[0].introduction
          //window.UE.getEditor('editor2').setContent(this.introduction)
          // console.log(this.introduction)
          this.plan = data.subproject[0].plan
          //window.UE.getEditor('editor3').setContent(this.plan)
          this.schsupport = data.subproject[0].schsupport
          //window.UE.getEditor('editor4').setContent(this.schsupport)
          this.result_1 = data.subproject[0].result_1  
          //window.UE.getEditor('editor5').setContent(this.result_1)
          this.parent = data.project[0].parent
          console.log(data.subproject[0].result)
          this.result = data.subproject[0].result.split(',')
          if (data.subproject[0].support === 0) {
            this.form.support = '教育厅还未最终敲定'
          } else {
            this.form.support = this.support[this.form.support].title
          }
         })
      })
    },
     getSelection() {
      let data = {}
      this.apiPost('admin/Report/DropdowmList', data).then(res => {
        this.handelResponse(res, data => {
          console.log(data.achievements)
          // this.options1 = data.support
          this.options2 = data.achievements
        })
      })
    },
    // 为编辑器设置placeholder
    // UESet() {
    //   window.UE.Editor.prototype.placeholder = function(justPlainText) {
    //     var _editor = this
    //     _editor.addListener('focus', function() {
    //       var localHtml = _editor.getPlainTxt()
    //       if ($.trim(localHtml) === $.trim(justPlainText)) {
    //         _editor.setContent(' ')
    //       }
    //     })
    //     _editor.addListener('blur', function() {
    //       var localHtml = _editor.getContent()
    //       if (!localHtml) {
    //         _editor.setContent(justPlainText)
    //       }
    //     })
    //     _editor.ready(function() {
    //       _editor.fireEvent('blur')
    //     })
    //   }
    //   //实例化编辑器example
    //   var editor = window.UE.getEditor('editor')
    //   editor.placeholder(
    //     '主要内容提示：1.内容应由项目主持人撰写；文章内容要层次清楚、观点明晰、用语准确、文风朴实，要有实质性内容，并具有整体性和系统性，不得简单排列篇章目录；成果形式为出版物，或者3000左右文字材料或调研报告，附图片及其他佐证材料复印件或原件，具体依据实际情况确定。2.项目预期研究计划的执行情况；成果研究内容及方法的创新程度、突出特色；成果的创新实践性以及社会影响和效益；成果存在的不足或欠缺，尚需深入研究的问题等。'
    //   )
    // },
    // 性别1男2女
    sexShow(row) {
      var sex = ''
      if (row.sex === 1) {
        sex = '男'
      } else if (row.sex === 2) {
        sex = '女'
      }
      return sex
    },
    // 提交前的验证
    submitCheck(form, subproject) {
      this.form.result = this.result.join()
      console.log(this.form.result)
      var checkResult = this.checkList(form, [
        {
          name: 'title',
          reg: ['notnull']
        },
        {
          name: 'theme',
          reg: ['notnull']
        },
        {
          name: 'research_direction',
          reg: ['notnull']
        },
        {
          name: 'finish_time',
          reg: ['notnull']
        },
        {
          name: 'word_count',
          reg: ['notnull']
        },
        {
          name: 'unit',
          reg: ['notnull']
        },
        {
          name: 'postal_address',
          reg: ['notnull']
        },{
          name: 'result',
          reg: ['notnull']
        },{
          name: 'train_support',
          reg: ['notnull']
        },{
          name: 'train_support_tj',
          reg: ['notnull']
        }
      ])
      if (_g.j2s(checkResult) === '{}') {

        if(this.introduction == '' ) {
           _g.toastMsg('error','请填写项目简介');
           return;
        }
        if(this.introduction == '') {
           _g.toastMsg('error','请填写项目方案')
           return;
        }  
        if(this.schsupport == '') {
          _g.toastMsg('error','请填写学校提供条件')
          return;
        }
        if(this.result_1 == '') {
          _g.toastMsg('error','请填写预期成果')
          return;
        }
        if(this.background == ''){
          _g.toastMsg('error','请填写项目背景')
          return;
        }
        this.submitUpdate()
            
      } else {
        for (const key in checkResult) {
          _g.toastMsg('warning', this.tips[key] + checkResult[key])
          break
        }
      }
    },
    // 提交修改的数据
    submitUpdate() {
      this.timeDeal()
      // console.log(this.fileList[0])
      
      this.form.schsupport = this.schsupport
      this.form.introduction = this.introduction
      this.form.plan = this.plan
      this.form.result_1 = this.result_1
      this.form.background = this.background
      // this.form.file_id = this.fileList[0].name
      let data = {
        fund: this.formExpense,
        subproject: this.form,
        partner: this.partner,
        ids: this.ids,
        // file_id: this.fileList[0].file_id
      }
     console.log(data)
      this.apiPost('admin/Report/TrainRevise', data).then(res => {
        this.handelResponse(res, data => {
          console.log(res)
          _g.toastMsg('success', '项目申报修改成功')
          this.$router.push({
            name: 'detailpro',
            params: { id: this.project_id }
          })
        })
      })
    },
    // 表单日期格式处理
    timeDeal() {
      let date = new Date(this.form.finish_time)
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      if (month < 10) {
        month = '0' + month
      }
      if (day < 10) {
        day = '0' + day
      }
      this.form.finish_time = year + '-' + month + '-' + day
    }
  },
  created() {
    _g.closeGlobalLoading()
    // this.init()
    
  },
  watch: {},
  computed: {},
  components: { UE },
  mounted() {
    this.getAllMsg()
    this.getSelection()
  },
  mixins: [http]
}
</script>
<style scoped>
.wrapper {
  position: relative;
  border-radius: 3px;
  background: #fff;
  border-top: 3px solid #d2d6de;
  margin-bottom: 20px;
  width: 100%;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  border-top-color: #3c8dbc;
  padding-bottom: 50px;
}
.header {
  padding-left: 15px;
}
.title {
  padding: 30px 40px 0 0;
  float: right;
}
.intro {
  text-align: center;
  background-color: #add5fe;
  border-radius: 4px 4px 0 0;
  line-height: 30px;
  margin-bottom: 30px;
}
.cell-width {
  width: 88%;
}
.apply_expense {
  padding-bottom: 20px;
  font-family: '微软雅黑';
  font-weight: 800;
  text-align: center;
}
.editor {
  padding: 0 3.5% 0 12.5%;
}
.left {
  width: 18%;
  text-align: right;
  padding-right: 10px;
  font-family: '微软雅黑';
}
.right {
  width: 32%;
  padding: 4px;
}
.red {
  padding-right: 5px;
}
.content {
  margin: 0 auto;
  border-color: #e8f6f9;
  font-size: 14px;
}
.expense-width {
  width: 60%;
}
.people-table {
  padding: 0 11.4% 0 11.4%;
}
.left {
  width: 200px;
  text-align: right;
  padding-right: 10px;
  font-family: '微软雅黑';
}
.right {
  width: 400px;
  padding: 4px;
}
.red {
  color: red;
  padding-right: 3px;
}
.content {
  border-color: #e8f6f9;
}
.content tr:nth-child(even) {
  background: #fff;
}
.content tr:nth-child(odd) {
  background: #f2f9ff;
}
</style>
